#include<iostream>  

using namespace std;

int main() {
	int gcd(int a, int b);
	int a, b, t, p;
	cin >> t;
	while (t--) {
		cin >> a >> b;
		p = gcd(a, b);
		cout << p << ' ' << a * b / p << endl;
	}
	return 0;
}
int gcd(int a, int b) {
	if (a < b) {
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
	while (b != 0) {
		a = a % b;
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
	}
	return a;
}
